# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Maintainer: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Corrado Primier <bardo@aur.archlinux.org>
# Contributor: Brad Fanella <bradfanella@archlinux.us>

pkgname=avrdude
epoch=1
pkgver=7.2
pkgrel=1
pkgdesc="Download/upload/manipulate the ROM and EEPROM contents of AVR microcontrollers"
arch=('loong64' 'x86_64')
url="https://github.com/avrdudes/avrdude/"
license=('GPL')
depends=('elfutils' 'hidapi' 'libftdi' 'libusb-compat' 'readline')
makedepends=('cmake' 'ninja')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/avrdudes/avrdude/archive/refs/tags/v${pkgver}.tar.gz
        https://github.com/avrdudes/avrdude/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.sig)
validpgpkeys=('EF497ABE47ED91B3FC3D7EA54D902FF7723BDEE9' '5E84F980C3CAFD4BB5841070F48CA81B69A85873' '56628323218C669FF578705C7E9EADC3030D34EB')
b2sums=('7bf86ea802bb150415a0d8c1ba884d5ff84b3d4bfb0e77470205d578001c1c19f782ddd37ae4235fba9f2ccc05247aea1723ebc2e1c71174c23b0986e835231e'
        'SKIP')

build() {
  cd ${pkgname}-${pkgver}

  cmake -B build \
    -G Ninja \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_SYSCONFDIR=/etc \
    -D CMAKE_BUILD_TYPE=RelWithDebInfo \
    -D BUILD_SHARED_LIBS=1 \
    -D HAVE_LINUXGPIO=1 \
    -D HAVE_LINUXSPI=1
  ninja -C build
}

package() {
  cd ${pkgname}-${pkgver}

  DESTDIR="${pkgdir}" ninja -C build install
}
